<template>
  <div class="mui-pages">
    <header class="mui-bar mui-bar-nav">
      <div class="header-common-title flex-justify-start">
        <div @click="fn.back()" class="mui-action-back">
          <img class="back-btn" src="../../../../static/images/back.png" />
        </div>
        <div class="header-search flex-center">组织生活会申请记录</div>
      </div>
    </header>
    <div class="mui-page-content">
      <div class="mui-scroll-wrapper">
        <div class="mui-scroll-wrapper work-message-lists">
          <cube-scroll
            ref="scroll"
            :options="options"
            @pulling-up="onPullingUp"
          >
            <cube-swipe>
              <transition-group name="swipe" tag="div">
                <div
                  v-for="(data, index) in swipeData"
                  :key="data.partyMeetingId"
                >
                  <p class="history-message flex-center">
                    {{ getTimeStr(data.meetTime) }}
                  </p>
                  <div class="work-message-item" @click="go(data)">
                    <div class="work-message-item-title">
                      <p class="schedule-item-world">
                        <b>会议主题：</b>{{ data.subject }}
                      </p>
                      <p class="schedule-item-world">
                        <b>创建人：</b>{{ data.createByName }}
                      </p>
                      <p class="schedule-item-world">
                        <b>会议时间：</b>{{ getTimeStr(data.meetTime) }}
                      </p>
                      <p v-if="!data.opinionInfo" class="schedule-item-world">
                        <b>申请状态：</b><span class="work-blue">申请中</span>
                      </p>
                      <p v-if="data.opinionInfo" class="schedule-item-world">
                        <b>审批结果：</b
                        ><span class="mine-lists-money">{{
                          data.opinionInfo
                        }}</span>
                      </p>
                    </div>
                    <div class="flex-between-center message-details">
                      <p>查看详情</p>
                      <span class="mui-icon mui-icon-arrowright"></span>
                    </div>
                  </div>
                </div>
              </transition-group>
            </cube-swipe>
            <!-- <div class="text-center no-data" v-if="swipeData.length===0">
              <img src="../../../../static/images/no_data.png" alt="">
              <p>暂无数据</p>
            </div> -->
            <!-- W noData -->
            <noData v-if="swipeData.length === 0"></noData>
            <onBottom v-else-if="onBottom"></onBottom>
          </cube-scroll>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import tools from "@/utils/tools";
import loginService from "@/service/loginService";
import moment from "moment";
export default {
  name: "organizationApply",
  data() {
    return {
      fn: tools,
      options: {
        pullUpLoad: true,
        scrollbar: false,
      },
      onBottom: false, // W onBottom
      swipeData: [],
      pageIndex: 0,
      flag: "1",
    };
  },
  created() {
    this.loadData();
  },
  methods: {
    loadData() {
      let userInfo = this.$store.state.userInfo;
      let partyGroupId = userInfo.partyMemberModel.partyGroupId;
      let data = {
        isApproval: "1",
        pageIndex: this.pageIndex,
        pageSize: 20,
        opinionType: "0,1,2",
        partyGroupId: partyGroupId,
      };
      if (tools.isDWB()) {
        delete data.isApproval;
      }
      loginService.getInsPartyMeetingApprovalLogList(data).then((res) => {
        if (res.code === 200 && res.data.length < 1) {
          this.$refs.scroll.forceUpdate && this.$refs.scroll.forceUpdate();
          return tools.tip("已无更多数据");
        }
        this.pageIndex++;
        this.swipeData = this.swipeData.concat(res.data);
        setTimeout(() => {
          this.$refs.scroll.forceUpdate &&
            this.$refs.scroll.forceUpdate(true, false);
          this.options.isPullUpLoad = false;
        }, 100);
      });
    },
    go(data) {
      this.$router.push({
        path: `/organizationApproveDetails/${data.partyMeetingId}/${data.approvalLogId}`,
      });
    },
    getTimeStr(time) {
      return moment(time).format("YYYY-MM-DD HH:mm");
    },
    onPullingUp() {
      console.log("onPullingUp");
      this.loadData();
    },
  },
};
</script>

<style scoped>
</style>
